package com.spring.boot.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spring.boot.entity.Contract;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Daniel ZTQ
 * @Date: 2021/01/01 12:13
 * @Description: TODO
 */
@Service
public interface ContractMapper extends BaseMapper<Contract> {

    /**
     * 根据合同uuid查询合同信息
     * */
    @Select("select * from Contract where contract_uuid=#{contractUuid}")
    Contract getContractByContractUuid(@Param("contractUuid")String contractUuid);

    /**
     * 根据用户uid查询合同信息
     * */
    @Select("select * from Contract where uid=#{uid}")
    List<Contract> getContractByContractUid(@Param("uid")String uid);

    /**
     * 根据合同uuid，修改合同类型
     * */
    @Update("update contract set type=#{type} where contract_uuid=#{contractUuid}")
    int updateContractType(@Param("type")String type,@Param("contractUuid")String contractUuid);

    /**
     * 查询所有合同信息
     * */
    @Select("select * from Contract")
    List<Contract> getAllContract();

    /**
     * 根据合同id查询合同信息
     * */
    @Select("select * from Contract where contract_id=#{contractId}")
    Contract getContractBycontractId(@Param("contractId") Integer contractId);

    /**
     * 根据合同id，修改合同类型为已理赔
     * */
    @Update("update contract set type='4' where contract_id=#{contractId}")
    int updateContractTypeById(@Param("contractId")String contractId);

    /**
     * 根据用户uid和type查询合同信息
     * */
    @Select("select * from Contract where uid=#{uid} and type=#{type}")
    List<Contract> getContractByContractUidAndType(@Param("uid")String uid,@Param("type")String type);

    /**
     * 根据type查询合同信息
     * */
    @Select("select * from Contract where type=#{type}")
    List<Contract> getContractBytype(@Param("type")String type);
}
